package com.share.jedis;

import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.JedisCluster;
import redis.clients.jedis.JedisPoolConfig;

import java.util.HashSet;
import java.util.Set;

/**
 * created by caifan 2018/12/14
 */
public class JedisTest {

    public static void main(String[] args) {
        Set<HostAndPort> hps = new HashSet<>();
        HostAndPort hostAndPort1 = new HostAndPort("192.168.2.10", 7001);
        HostAndPort hostAndPort2 = new HostAndPort("192.168.2.10", 7002);
        HostAndPort hostAndPort3 = new HostAndPort("192.168.2.11", 7001);
        HostAndPort hostAndPort4 = new HostAndPort("192.168.2.11", 7002);
        HostAndPort hostAndPort5 = new HostAndPort("192.168.2.12", 7001);
        HostAndPort hostAndPort6 = new HostAndPort("192.168.2.12", 7002);
        HostAndPort hostAndPort7 = new HostAndPort("192.168.2.13", 7001);
        HostAndPort hostAndPort8 = new HostAndPort("192.168.2.13", 7002);
        hps.add(hostAndPort1);
        hps.add(hostAndPort2);
        hps.add(hostAndPort3);
        hps.add(hostAndPort4);
        hps.add(hostAndPort5);
        hps.add(hostAndPort6);
        hps.add(hostAndPort7);
        hps.add(hostAndPort8);
        JedisPoolConfig poolConfig = new JedisPoolConfig();
        poolConfig.setMaxIdle(100);

        JedisCluster jedisCluster = new JedisCluster(hps, 3000, 1000,3, "root", poolConfig);
        jedisCluster.set("email", "caifan@cashbus.com");

    }
}
